function grep = gs_gridrep(fvx,fvy,lvx,lvy,nx,ny,dx,dy)
%
%grep = gs_grid_rep(fvx,fvy,lvx,lvy,nx,ny,dx,dy);
%
% This function generates a grid report, in which 
%   fvx, fvy: down-left corner;
%   lvx, lvy: top-right corner;
%   nx, ny  : grid elments along x,y;
%   dx, dy  : x-,y-grid pass.
%
% It is called by GS_GRIDGENE.

% G. Teza, 2005

if nargin < 8, help gs_gridrep, error('Not enough input data'); end

sdfx = nu_dd(fvx,2);  % Ancillary function, see below
sdfy = nu_dd(fvy,2);
sdlx = nu_dd(lvx,2);
sdly = nu_dd(lvy,2);
sddx = nu_dd(dx,2);
sddy = nu_dd(dy,2);
grep = sprintf(...
    '%s\n\n%s\n %s (%s,%s)\n %s (%s,%s);\n%s\n%s%d, %s%d;\n%s\n%s%s, %s%s.',...
    'GRID REPORT','VERTICES:','FIRST:',sdfx,sdfy,'LAST:',sdlx,sdly,...
    'NUMBER OF GRID ELEMENTS:',' nx = ',nx,' ny = ',ny,...
    'GRID SPACING',' dx = ',sddx,' dy = ',sddy);

%--- ancillary function ---

function rd = nu_dd(r,nd)
% For the representation of a number as
% '%nip.ndf', in which nip is the number of digits
% of its integer part and nf is the number of decimals.
srd = ['%' num2str(length(num2str(fix(r)))) '.' num2str(nd) 'f'];
     % (The result is the format for the representation)
rd = sprintf(sprintf('%s',srd),r);